/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
/*
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 * Description:  NvM 模块Callout函数的源文件.
 */


#include "nvm.h"

{%- set user_codes = get_bsw_callout_user_code_list() %}
/******************USER CODE STARTS!************THIS COMMENT WILL BE SAVED!***************/
{%- if "head_usercode" in user_codes.keys() and user_codes["head_usercode"] != {} and user_codes["head_usercode"] != [] %}
{%- for value in user_codes["head_usercode"] %}
{{value.strip('\n')}}
{%- endfor %}
{%- endif %}
/******************USER CODE ENDS!**************THIS COMMENT WILL BE SAVED!***************/

#define NVM_START_SEC_CODE
#include "nvm_memmap.h"
//Multiblock callback
FUNC(void, NVM_CODE) nvm_multi_block_cbk(uint8 service_id, nvm_request_result_type job_result)
{
    (void)service_id;
    (void)job_result;
/******************USER CODE STARTS!************THIS COMMENT WILL BE SAVED!***************/
{%- if "nvm_multi_block_cbk" in user_codes.keys() and user_codes["nvm_multi_block_cbk"] != {} and user_codes["nvm_multi_block_cbk"] != [] %}
{%- for value in user_codes["nvm_multi_block_cbk"] %}
{{value.strip('\n')}}
{%- endfor %}
{%- endif %}
/******************USER CODE ENDS!**************THIS COMMENT WILL BE SAVED!***************/
}

//Singleblock callback
FUNC(Std_ReturnType, NVM_CODE) nvm_single_block_cbk(uint8 service_id, nvm_request_result_type job_result)
{
    (void)service_id;
    (void)job_result;
/******************USER CODE STARTS!************THIS COMMENT WILL BE SAVED!***************/
{%- if "nvm_single_block_cbk" in user_codes.keys() and user_codes["nvm_single_block_cbk"] != {} and user_codes["nvm_single_block_cbk"] != [] %}
{%- for value in user_codes["nvm_single_block_cbk"] %}
{{value.strip('\n')}}
{%- endfor %}
{%- endif %}
/******************USER CODE ENDS!**************THIS COMMENT WILL BE SAVED!***************/
    return E_OK;
}
#define NVM_STOP_SEC_CODE
#include "nvm_memmap.h"
